package com.xbao.controller;

import com.xbao.core.http.CommRequest;
import com.xbao.core.http.CommResult;
import com.xbao.model.MySpread;
import com.xbao.model.SpreadTemplate;
import com.xbao.model.req.MySpreadReq;
import com.xbao.model.vo.MySpreadVo;
import com.xbao.service.MySpreadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Api(value = "/myspread", tags = "myspread")
@RequestMapping(value = "myspread")
@Controller
@EnableAutoConfiguration
public class MySpreadController  extends BaseController{
    @Resource
    private MySpreadService mySpreadService;






    @ApiOperation(value = "list", notes = "list")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public CommResult<List<MySpreadVo>> query(@RequestBody CommRequest<MySpreadReq> spreadTemplateCommRequest) {
        List<MySpreadVo> list=mySpreadService.querySpread(spreadTemplateCommRequest.getData());
        return new CommResult<List<MySpreadVo>>(list);
    }

    public CommResult<List<MySpreadVo>> add(@RequestBody CommRequest<MySpreadReq> spreadTemplateCommRequest) {
        mySpreadService.addMySpread(spreadTemplateCommRequest.getData());
        return result();
    }
    public CommResult<List<MySpreadVo>> update(@RequestBody CommRequest<MySpreadReq> spreadTemplateCommRequest) {
        mySpreadService.updateMySpread(spreadTemplateCommRequest.getData());
        return result();
    }
    public CommResult delete(@RequestBody CommRequest<MySpreadReq> spreadTemplateCommRequest) {
        mySpreadService.deleteSpread(spreadTemplateCommRequest.getData());
        return result();
    }
}
